Python 查询 GitLab commit 次数

石朝辉2021-02-03 22:07PythonPython Git

转载请注明出处,点击此处open in new window 查看更多精彩内容

年底了,看看自己这一年总共提交了多少次代码吧。

安装 python-gitlab

# Python2
pip install python-gitlab

# Python3
pip3 install python-gitlab

下载脚本

我已经写好了脚本,点击这里获取脚本和配置文件open in new window

脚本和配置文件

  • config.py 配置文件,需要获取自己的配置信息并填写到该文件中。
  • queryer.py 查询脚本,修改配置后运行该 脚本即可启动查询。

获取 GitLab 地址和 Access Token

GitLab 地址

GitLab 地址即安装 GitLab 的服务器地址,如:https://gitlab.***.com

GitLab 地址

Access Token

登录 GitLab 账号, 访问 https://gitlab.***.com/profile/personal_access_tokens 页面。

在该页面填写 Name 并勾选 api ,最后点击 Create personal access token 按钮即可生成 Token

Access Token

保存生成的 Token,否则刷新页面之后就再也看不到它了。

查询自己参与的项目

登录 GitLab 账号,访问 https://gitlab.***.com/users/[userName]/contributed 页面即可查看自己参与的项目列表。

[userName] 需要改完自己的用户名

参与的项目

运行

# Python2
python your_path/queryer.py

# Python3
python3 your_path/queryer.py
最后更新于 2024-02-04 02:20:03